<template>
	<view class="data-item">
		<view class="order-type">
			<view>看房申请: <text>{{value.apply_no}}</text></view>
			<view style="font-weight: 400;color: #999999;">已预约<text style="font-weight: 400;margin: 0 10rpx; color: #2C72FF;">{{value.pi_looking_room.company_look_num || 0}}</text>次</view>
		</view>
		<view class="order-info">
			<view class="info-item"><view class="key">申请人：</view>{{value.pi_looking_room.apply_user_name}}</view>
			<view class="info-item"><view class="key">联系方式：</view>{{value.pi_looking_room.contact_phone || '无'}}</view>
			<view class="info-item"><view class="key">单位名称：</view>{{value.pi_looking_room.company_name || '无'}}</view>
			<view class="info-item"><view class="key">看房时间：</view>{{value.pi_looking_room.start_time || '无'}}</view>
			<view class="info-item"><view class="key">接待时间：</view>{{value.pi_looking_room.accept_starttime || '无'}}</view>
		</view>
		<view v-for="(itemRoom, indexRoom) of value.pi_looking_room.pi_looking_property_dets" :key="indexRoom" class="target-info">
			<image v-if="itemRoom.property_image" mode="aspectFill" class="img" :src="formatPropertyImage(itemRoom.property_image) | formatImgPath('120', '120')"/>
			<image v-else mode="aspectFill" class="img" :src="(imgUrl+'/wx/default_img.jpg')"/>
			<view class="info" style="flex: 1;">
				<view class="top"  >
					<view class="name" style="display: flex;justify-content: space-between; align-items: center;">
						<view>{{itemRoom.tag_name}}</view>
						<view style="font-weight: 400;color: #999999;">已看房<text style="margin: 0 10rpx; color: #2C72FF;">{{itemRoom.company_look_num}}</text>次</view>
					</view>
					<view class="desc">{{itemRoom.floor_area}}m/{{itemRoom.storey}}层/{{itemRoom.building}}楼</view>
				</view>
				<view class="fee">
					<view class="amount">{{(itemRoom.pricing_amount * itemRoom.floor_area || "") | formatMoneyNo00}}元/月</view>
				</view>
			</view>
		</view>
		<view v-if="value.pi_looking_room.jd_status == 'APPLYED'" class="handle-btn">
			<view @click="acceptLookRoom">立即受理</view>
		</view>
		<view v-if="value.pi_looking_room.jd_status == 'REGISTER'" class="handle-btn">
			<view @click="doneLookRoom">立即登记</view>
		</view>
		<view v-if="value.pi_looking_room.jd_status == 'VISIT'" class="handle-btn">
			<view @click="visitLookRoom">回访</view>
		</view>
		<view v-if="value.pi_looking_room.jd_status == 'COMPLETE' || value.pi_looking_room.jd_status == 'BOOKING_FAIL'" class="handle-btn">
			<view @click="detailLookRoom">查看详情</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'LookRoom',
	props:{
		value: {
			type: Object,
			default: ()=>{
				return {}
			}
		}
	},
	data(){
		return {
			imgUrl:this.$config.BASE_imgUrl,
		}
	},
	created(){
	},
	methods:{
		formatPropertyImage(property_image) {
			let property_images = property_image.split(";");
			for (let item of property_images) {
				if (!item) continue
				return item
			}
			return property_image
		},
		acceptLookRoom(){
			uni.navigateTo({
				url: '/pagesA/check-house/check-house-accept?lookId=' + this.value.pi_looking_room.look_id
			})
		},
		doneLookRoom(){
			uni.navigateTo({
				url: '/pagesA/check-house/check-house-done?lookId=' + this.value.pi_looking_room.look_id
			})
		},
		visitLookRoom(){
			uni.navigateTo({
				url: '/pagesA/check-house/check-house-revisit?lookId=' + this.value.pi_looking_room.look_id
			})
		},
		detailLookRoom(){
			uni.navigateTo({
				url: '/pagesA/check-house/check-house-detail?lookId=' + this.value.pi_looking_room.look_id
			})
		},
	}
}
</script>

<style lang="scss" scoped>
.data-item{
	// display: flex;
	// margin-bottom: 30rpx;
	.order-type{
		display: flex;
		justify-content: space-between;
		font-size: 28rpx;
		color: #999999;
		>view:first-child{
			font-size: 32rpx;
			font-weight: bolder;
			color: #333333;
		}
	}
	.order-info{
		margin: 30rpx 0;
		.info-item{
			display: flex;
			font-size: 28rpx;
			color: #333333;
			line-height: 50rpx;
			.key{
				min-width: 150rpx;
				font-size: 28rpx;
				color: #999999;
			}
			.info-imgs{
				display: flex;
				flex-wrap: wrap;
				.img-item{
					width: 120rpx;
					height: 120rpx;
					margin: 2rpx 2rpx 0 0;
				}
			}
		}
	}
	.handle-btn{
		border-top: 1px solid #F5F5F5;
		height: 95rpx;
		margin-top: 20rpx;
		display: flex;
		> view{
			height: 95rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 32rpx;
			font-weight: bolder;
			color: #333333;
			flex: 1;
		}
		& :last-child{
			color: #0055FE;
		}
	}
	.target-info{
		flex: 1;
		display: flex;
		padding-bottom: 20rpx;
		.img{
			width: 260rpx;
			height: 295rpx;
			border-radius: 10rpx;
			margin-right: 20rpx;
		}
		.top{
			.name{
				font-size: 28rpx;
				font-weight: bolder;
				color: #333333;
			}
			.desc{
				font-size: 28rpx;
				color: #999999;
				margin-top: 10rpx;
			}
		}
		.fee{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 30rpx;
			.amount{
				font-size: 36rpx;
				color: #FF3737;
			}
			.common-btn{
				height: 60rpx;
				width: 160rpx;
				font-size: 28rpx;
				margin: 0;
			}
		}
	}
}

</style>
